//+---------------------------------------------------------------------------
//
// Copyright (C) Microsoft Corporation, 2008
//
// File: DataPoint.cs
//
// Contents: Simple DataPoint class which holds all data for a signle event or instance to be logged
//
// Created by: Adam Wardynski (AdamWa) 2/4/2008
//
//----------------------------------------------------------------------------
using System;
using System.Collections.Generic;

namespace Microsoft.Reputation.Services
{
    /// <summary>
    /// Simple DataPoint class which holds all data for a single event or instance to be logged
    /// </summary>
    public class DataPoint
    {
        private Dictionary<string, object> m_dataStore;

        public DataPoint()
        {
            m_dataStore = new Dictionary<string, object>();
        }

        /// <summary>
        /// Adds a single string element of the data point
        /// </summary>
        /// <param name="name">name of the DataPointSchemaElement</param>
        /// <param name="data">data of the DataPointSchemaElement</param>
        public void Add(string name, string data)
        {
            // add with out validation
            m_dataStore.Add(name, data);
        }

        /// <summary>
        /// Adds a single int element of the data point
        /// </summary>
        /// <param name="name">name of the DataPointSchemaElement</param>
        /// <param name="data">data of the DataPointSchemaElement</param>
        public void Add(string name, int data)
        {
            // add with out validation
            m_dataStore.Add(name, data);
        }

        /// <summary>
        /// Try to get value of element with given name
        /// </summary>
        /// <param name="name">name of element</param>
        /// <param name="value">value of element if found, null otherwise</param>
        /// <returns>true if element was found, false otherwise</returns>
        public bool TryGetValue(string name, out object value)
        {
            return m_dataStore.TryGetValue(name, out value);
        }
    }
}